<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>
  Hantsy
  
  Bai
  
  
  | Deploying Jakarta EE 9 applications to Payara using Cargo maven plugin
  
</title>
<meta name="description" content="My personal website focusing on Java EE/Jakarta EE and Spring.
">

<!-- Open Graph -->


<!-- Bootstrap & MDB -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
  rel="stylesheet" integrity="sha512-MoRNloxbStBcD8z3M/2BmnT+rg4IsMxPkXaGh2zD6LGNNFE80W3onsAhRcMAMrSoyWL9xD7Ert0men7vR8LUZg==" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.19.1/css/mdb.min.css"
  integrity="sha512-RO38pBRxYH3SoOprtPTD86JFOclM51/XTIdEPh5j8sj4tp8jmQIx26twG52UaLi//hQldfrh7e51WzP9wuP32Q==" crossorigin="anonymous" />

<!-- Fonts & Icons -->
<link rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css"
  integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous">
<link rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/academicons/1.9.0/css/academicons.min.css"
  integrity="sha512-W4yqoT1+8NLkinBLBZko+dFB2ZbHsYLDdr50VElllRcNt2Q4/GSs6u71UHKxB7S6JEMCp5Ve4xjh3eGQl/HRvg==" crossorigin="anonymous">
<link rel="stylesheet" type="text/css"
  href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:100,300,400,500,700|Material+Icons">

<!-- Code Syntax Highlighting -->
<link rel="stylesheet"
  href="https://gitcdn.link/repo/jwarby/jekyll-pygments-themes/master/github.css" />

<!-- Styles -->
<link rel="shortcut icon" href="/assets/img/favicon.ico">
<link rel="stylesheet" href="/assets/css/main.css">

<link rel="canonical" href="/blog/2020/deploying-jakarta-ee-9-applications-to-payara-using-cargo-maven-plugin/">

<!-- JQuery -->
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>


<!-- Theming-->

<script src="/assets/js/theme.js"></script>
<!-- Load DarkMode JS -->
<script src="/assets/js/dark_mode.js"></script>



<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-18SZ2W3GXD"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments); }
  gtag('js', new Date());

  gtag('config', 'G-18SZ2W3GXD');
</script>




  
<!-- MathJax -->
<script type="text/javascript">
  window.MathJax = {
    tex: {
      tags: 'ams'
    }
  };
</script>
<script defer type="text/javascript" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3.1.2/es5/tex-mml-chtml.js"></script>
<script defer src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>


  <link type="application/atom+xml" rel="alternate" href="/feed.xml" title="blank" />
  <!-- Begin Jekyll SEO tag v2.7.1 -->
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="Deploying Jakarta EE 9 applications to Payara using Cargo maven plugin" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="Payara Community 5.2020.5 has introduced tech preview functionality to run Jakarta EE 9 on Payara Server and Micro, more details please go to the release notes. Originally Payara was a fork of the open-sourced Glassfish, but it includes a bundle of new features that not existed in Glassfish. Numerous improvements and quicker bugfixes in comparison to the existing GlassfishJava 11(or above) supportBuilt-in Microprofile support and ready for cloud native applicationsMany third-party services integration.Comprehensive documentation and technical guidesCommercial support available for paid enterprise users. Payara Community is also open sourced, for developers, you use it as an alternative to Glassfish to get better development experience. Prerequisites Make sure you have installed the following software. Java 8 or Java 11 (OpenJDK or AdoptOpenJDK)Payara Community 5.2020.6Apache MavenGet to know the basic of Cargo maven plugin. Deploy to local Payara server Cargo maven plugin provides a separate payara container for Payara server. Assume you have downloaded a copy of Payara Community dist, and extracted the files into your local disk. Add the following configuration in pom.xml to use the existing Payara domain configuration to run your Jakarta EE 9 applications on the local Payara server. &lt;properties&gt; &lt;glassfish.home&gt;[ Payara install dir]&lt;/glassfish.home&gt; &lt;glassfish.domainDir&gt;${glassfish.home}/glassfish/domains&lt;/glassfish.domainDir&gt; &lt;glassfish.domainName&gt;domain1&lt;/glassfish.domainName&gt;&lt;/properties&gt;&lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;payara&lt;/containerId&gt; &lt;type&gt;installed&lt;/type&gt; &lt;home&gt;${glassfish.home}&lt;/home&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;existing&lt;/type&gt; &lt;home&gt;${glassfish.domainDir}&lt;/home&gt; &lt;properties&gt; &lt;cargo.glassfish.domain.name&gt;${glassfish.domainName}&lt;/cargo.glassfish.domain.name&gt; &lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt;&lt;/build&gt; The above configuration is almost same as the one we have discussed in previous Glassfish post, but we used containerId payara here. Open a terminal, execute the following command to run your application on the Payara server. mvn clean package cargo:run -Ppayara-local The above command will execute a serise of tasks. Build the project and package it into a war archive in the target folderStarts up Payara server using the existing domain1 configurationDeploy the packaged war to the running server If you want to use a refresh domain configuration every time to run your applications, try to set the configuration type to standalone. Change the server configuration section to the following. &lt;configuration&gt; &lt;type&gt;standalone&lt;/type&gt; &lt;properties&gt; &lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt; &lt;/properties&gt;&lt;/configuration&gt; A little different from the existing configuration, it will create a new domain configuration in the target folder instead of the default domain1 in the Payara server. In the CI service, such as Github actions, I would like use the official maven-dependency-plugin to prepare a refresh copy of Payara server. &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;unpack&lt;/id&gt; &lt;phase&gt;process-resources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;unpack&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;artifactItems&gt; &lt;artifactItem&gt; &lt;groupId&gt;fish.payara.distributions&lt;/groupId&gt; &lt;artifactId&gt;payara&lt;/artifactId&gt; &lt;version&gt;${payara.version}&lt;/version&gt; &lt;type&gt;zip&lt;/type&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;/artifactItems&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt;&lt;/plugin&gt; Change the glassfish.home property to the following. &lt;glassfish.home&gt;${project.build.directory}/payara5&lt;/glassfish.home&gt; To stop the server, just send a CTRL+C to the running console to stop it. Deploy to a running Payara server Use a remote deployer and runtime configuration, you can use Cargo maven plugin to deploy the application to a running Payara, esp. the Payara server is located in a remote server. &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;payara&lt;/containerId&gt; &lt;type&gt;remote&lt;/type&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;runtime&lt;/type&gt; &lt;properties&gt; &lt;cargo.remote.username&gt;admin&lt;/cargo.remote.username&gt; &lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt; &lt;cargo.glassfish.admin.port&gt;4848&lt;/cargo.glassfish.admin.port&gt; &lt;cargo.hostname&gt;localhost&lt;/cargo.hostname&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;!-- provides JSR88 client API to deploy on Glassfish/Payara Server --&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.main.deployment&lt;/groupId&gt; &lt;artifactId&gt;deployment-client&lt;/artifactId&gt; &lt;version&gt;5.1.0&lt;/version&gt; &lt;!--&lt;version&gt;${glassfish.version}&lt;/version&gt;--&gt; &lt;/dependency&gt; &lt;/dependencies&gt;&lt;/plugin&gt; The above configuration is almost same as the one from Glassfish doc. For a remote server, you can not start and stop the Payara server. Before deploying applications, make sure it is running and accessible from your local environment. Use deploy and undeploy goals to perform the deploy and undeploy tasks. # deploy applicationsmvn clean package cargo:deploy -Ppayara-remote # undeploymvn cargo:undeploy -Ppayara-remote Verifying the deployed application When the application is deployed successfully, you use curl to verify if the deployed application. curl http://localhost:8080/jakartaee9-starter-boilerplate/api/greeting/Hantsy{&quot;message&quot;:&quot;Say Hello to Hantsy at 2020-11-14T15:56:10.099&quot;} Note: In fact, you can use the glassfish5x containerId to deploy Jakarta EE 9 applications to Payara server, and in reverse I think it is also fine when using the payara containerId to deploy the application to Glassfish v6. Grab the source codes from my github. &lt;hr&gt;&lt;p&gt;Deploying Jakarta EE 9 applications to Payara using Cargo maven plugin was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.&lt;/p&gt;" />
<meta property="og:description" content="Payara Community 5.2020.5 has introduced tech preview functionality to run Jakarta EE 9 on Payara Server and Micro, more details please go to the release notes. Originally Payara was a fork of the open-sourced Glassfish, but it includes a bundle of new features that not existed in Glassfish. Numerous improvements and quicker bugfixes in comparison to the existing GlassfishJava 11(or above) supportBuilt-in Microprofile support and ready for cloud native applicationsMany third-party services integration.Comprehensive documentation and technical guidesCommercial support available for paid enterprise users. Payara Community is also open sourced, for developers, you use it as an alternative to Glassfish to get better development experience. Prerequisites Make sure you have installed the following software. Java 8 or Java 11 (OpenJDK or AdoptOpenJDK)Payara Community 5.2020.6Apache MavenGet to know the basic of Cargo maven plugin. Deploy to local Payara server Cargo maven plugin provides a separate payara container for Payara server. Assume you have downloaded a copy of Payara Community dist, and extracted the files into your local disk. Add the following configuration in pom.xml to use the existing Payara domain configuration to run your Jakarta EE 9 applications on the local Payara server. &lt;properties&gt; &lt;glassfish.home&gt;[ Payara install dir]&lt;/glassfish.home&gt; &lt;glassfish.domainDir&gt;${glassfish.home}/glassfish/domains&lt;/glassfish.domainDir&gt; &lt;glassfish.domainName&gt;domain1&lt;/glassfish.domainName&gt;&lt;/properties&gt;&lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;payara&lt;/containerId&gt; &lt;type&gt;installed&lt;/type&gt; &lt;home&gt;${glassfish.home}&lt;/home&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;existing&lt;/type&gt; &lt;home&gt;${glassfish.domainDir}&lt;/home&gt; &lt;properties&gt; &lt;cargo.glassfish.domain.name&gt;${glassfish.domainName}&lt;/cargo.glassfish.domain.name&gt; &lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt;&lt;/build&gt; The above configuration is almost same as the one we have discussed in previous Glassfish post, but we used containerId payara here. Open a terminal, execute the following command to run your application on the Payara server. mvn clean package cargo:run -Ppayara-local The above command will execute a serise of tasks. Build the project and package it into a war archive in the target folderStarts up Payara server using the existing domain1 configurationDeploy the packaged war to the running server If you want to use a refresh domain configuration every time to run your applications, try to set the configuration type to standalone. Change the server configuration section to the following. &lt;configuration&gt; &lt;type&gt;standalone&lt;/type&gt; &lt;properties&gt; &lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt; &lt;/properties&gt;&lt;/configuration&gt; A little different from the existing configuration, it will create a new domain configuration in the target folder instead of the default domain1 in the Payara server. In the CI service, such as Github actions, I would like use the official maven-dependency-plugin to prepare a refresh copy of Payara server. &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;unpack&lt;/id&gt; &lt;phase&gt;process-resources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;unpack&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;artifactItems&gt; &lt;artifactItem&gt; &lt;groupId&gt;fish.payara.distributions&lt;/groupId&gt; &lt;artifactId&gt;payara&lt;/artifactId&gt; &lt;version&gt;${payara.version}&lt;/version&gt; &lt;type&gt;zip&lt;/type&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;/artifactItems&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt;&lt;/plugin&gt; Change the glassfish.home property to the following. &lt;glassfish.home&gt;${project.build.directory}/payara5&lt;/glassfish.home&gt; To stop the server, just send a CTRL+C to the running console to stop it. Deploy to a running Payara server Use a remote deployer and runtime configuration, you can use Cargo maven plugin to deploy the application to a running Payara, esp. the Payara server is located in a remote server. &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;payara&lt;/containerId&gt; &lt;type&gt;remote&lt;/type&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;runtime&lt;/type&gt; &lt;properties&gt; &lt;cargo.remote.username&gt;admin&lt;/cargo.remote.username&gt; &lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt; &lt;cargo.glassfish.admin.port&gt;4848&lt;/cargo.glassfish.admin.port&gt; &lt;cargo.hostname&gt;localhost&lt;/cargo.hostname&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;!-- provides JSR88 client API to deploy on Glassfish/Payara Server --&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.main.deployment&lt;/groupId&gt; &lt;artifactId&gt;deployment-client&lt;/artifactId&gt; &lt;version&gt;5.1.0&lt;/version&gt; &lt;!--&lt;version&gt;${glassfish.version}&lt;/version&gt;--&gt; &lt;/dependency&gt; &lt;/dependencies&gt;&lt;/plugin&gt; The above configuration is almost same as the one from Glassfish doc. For a remote server, you can not start and stop the Payara server. Before deploying applications, make sure it is running and accessible from your local environment. Use deploy and undeploy goals to perform the deploy and undeploy tasks. # deploy applicationsmvn clean package cargo:deploy -Ppayara-remote # undeploymvn cargo:undeploy -Ppayara-remote Verifying the deployed application When the application is deployed successfully, you use curl to verify if the deployed application. curl http://localhost:8080/jakartaee9-starter-boilerplate/api/greeting/Hantsy{&quot;message&quot;:&quot;Say Hello to Hantsy at 2020-11-14T15:56:10.099&quot;} Note: In fact, you can use the glassfish5x containerId to deploy Jakarta EE 9 applications to Payara server, and in reverse I think it is also fine when using the payara containerId to deploy the application to Glassfish v6. Grab the source codes from my github. &lt;hr&gt;&lt;p&gt;Deploying Jakarta EE 9 applications to Payara using Cargo maven plugin was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.&lt;/p&gt;" />
<meta property="og:site_name" content="blank" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2020-12-05T00:00:00+00:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Deploying Jakarta EE 9 applications to Payara using Cargo maven plugin" />
<script type="application/ld+json">
{"datePublished":"2020-12-05T00:00:00+00:00","description":"Payara Community 5.2020.5 has introduced tech preview functionality to run Jakarta EE 9 on Payara Server and Micro, more details please go to the release notes. Originally Payara was a fork of the open-sourced Glassfish, but it includes a bundle of new features that not existed in Glassfish. Numerous improvements and quicker bugfixes in comparison to the existing GlassfishJava 11(or above) supportBuilt-in Microprofile support and ready for cloud native applicationsMany third-party services integration.Comprehensive documentation and technical guidesCommercial support available for paid enterprise users. Payara Community is also open sourced, for developers, you use it as an alternative to Glassfish to get better development experience. Prerequisites Make sure you have installed the following software. Java 8 or Java 11 (OpenJDK or AdoptOpenJDK)Payara Community 5.2020.6Apache MavenGet to know the basic of Cargo maven plugin. Deploy to local Payara server Cargo maven plugin provides a separate payara container for Payara server. Assume you have downloaded a copy of Payara Community dist, and extracted the files into your local disk. Add the following configuration in pom.xml to use the existing Payara domain configuration to run your Jakarta EE 9 applications on the local Payara server. &lt;properties&gt; &lt;glassfish.home&gt;[ Payara install dir]&lt;/glassfish.home&gt; &lt;glassfish.domainDir&gt;${glassfish.home}/glassfish/domains&lt;/glassfish.domainDir&gt; &lt;glassfish.domainName&gt;domain1&lt;/glassfish.domainName&gt;&lt;/properties&gt;&lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;payara&lt;/containerId&gt; &lt;type&gt;installed&lt;/type&gt; &lt;home&gt;${glassfish.home}&lt;/home&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;existing&lt;/type&gt; &lt;home&gt;${glassfish.domainDir}&lt;/home&gt; &lt;properties&gt; &lt;cargo.glassfish.domain.name&gt;${glassfish.domainName}&lt;/cargo.glassfish.domain.name&gt; &lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt;&lt;/build&gt; The above configuration is almost same as the one we have discussed in previous Glassfish post, but we used containerId payara here. Open a terminal, execute the following command to run your application on the Payara server. mvn clean package cargo:run -Ppayara-local The above command will execute a serise of tasks. Build the project and package it into a war archive in the target folderStarts up Payara server using the existing domain1 configurationDeploy the packaged war to the running server If you want to use a refresh domain configuration every time to run your applications, try to set the configuration type to standalone. Change the server configuration section to the following. &lt;configuration&gt; &lt;type&gt;standalone&lt;/type&gt; &lt;properties&gt; &lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt; &lt;/properties&gt;&lt;/configuration&gt; A little different from the existing configuration, it will create a new domain configuration in the target folder instead of the default domain1 in the Payara server. In the CI service, such as Github actions, I would like use the official maven-dependency-plugin to prepare a refresh copy of Payara server. &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;unpack&lt;/id&gt; &lt;phase&gt;process-resources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;unpack&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;artifactItems&gt; &lt;artifactItem&gt; &lt;groupId&gt;fish.payara.distributions&lt;/groupId&gt; &lt;artifactId&gt;payara&lt;/artifactId&gt; &lt;version&gt;${payara.version}&lt;/version&gt; &lt;type&gt;zip&lt;/type&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;/artifactItems&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt;&lt;/plugin&gt; Change the glassfish.home property to the following. &lt;glassfish.home&gt;${project.build.directory}/payara5&lt;/glassfish.home&gt; To stop the server, just send a CTRL+C to the running console to stop it. Deploy to a running Payara server Use a remote deployer and runtime configuration, you can use Cargo maven plugin to deploy the application to a running Payara, esp. the Payara server is located in a remote server. &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;payara&lt;/containerId&gt; &lt;type&gt;remote&lt;/type&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;runtime&lt;/type&gt; &lt;properties&gt; &lt;cargo.remote.username&gt;admin&lt;/cargo.remote.username&gt; &lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt; &lt;cargo.glassfish.admin.port&gt;4848&lt;/cargo.glassfish.admin.port&gt; &lt;cargo.hostname&gt;localhost&lt;/cargo.hostname&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;!-- provides JSR88 client API to deploy on Glassfish/Payara Server --&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.glassfish.main.deployment&lt;/groupId&gt; &lt;artifactId&gt;deployment-client&lt;/artifactId&gt; &lt;version&gt;5.1.0&lt;/version&gt; &lt;!--&lt;version&gt;${glassfish.version}&lt;/version&gt;--&gt; &lt;/dependency&gt; &lt;/dependencies&gt;&lt;/plugin&gt; The above configuration is almost same as the one from Glassfish doc. For a remote server, you can not start and stop the Payara server. Before deploying applications, make sure it is running and accessible from your local environment. Use deploy and undeploy goals to perform the deploy and undeploy tasks. # deploy applicationsmvn clean package cargo:deploy -Ppayara-remote # undeploymvn cargo:undeploy -Ppayara-remote Verifying the deployed application When the application is deployed successfully, you use curl to verify if the deployed application. curl http://localhost:8080/jakartaee9-starter-boilerplate/api/greeting/Hantsy{&quot;message&quot;:&quot;Say Hello to Hantsy at 2020-11-14T15:56:10.099&quot;} Note: In fact, you can use the glassfish5x containerId to deploy Jakarta EE 9 applications to Payara server, and in reverse I think it is also fine when using the payara containerId to deploy the application to Glassfish v6. Grab the source codes from my github. &lt;hr&gt;&lt;p&gt;Deploying Jakarta EE 9 applications to Payara using Cargo maven plugin was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.&lt;/p&gt;","mainEntityOfPage":{"@type":"WebPage","@id":"/blog/2020/deploying-jakarta-ee-9-applications-to-payara-using-cargo-maven-plugin/"},"url":"/blog/2020/deploying-jakarta-ee-9-applications-to-payara-using-cargo-maven-plugin/","@type":"BlogPosting","headline":"Deploying Jakarta EE 9 applications to Payara using Cargo maven plugin","dateModified":"2020-12-05T00:00:00+00:00","@context":"https://schema.org"}</script>
<!-- End Jekyll SEO tag -->

</head>

<body
  class="fixed-top-nav ">

  <!-- Header -->

  <header>

    <!-- Nav Bar -->
    <nav id="navbar" class="navbar navbar-light navbar-expand-sm fixed-top">
    <div class="container">
      
      <a class="navbar-brand title font-weight-lighter" href="/">
       <span class="font-weight-bold">Hantsy</span>   Bai
      </a>
      
      <!-- Navbar Toggle -->
      <button class="navbar-toggler collapsed ml-auto" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar top-bar"></span>
        <span class="icon-bar middle-bar"></span>
        <span class="icon-bar bottom-bar"></span>
      </button>
      <div class="collapse navbar-collapse text-right" id="navbarNav">
        <ul class="navbar-nav ml-auto flex-nowrap">
          <!-- About -->
          <li class="nav-item ">
            <a class="nav-link" href="/">
              about
              
            </a>
          </li>
          
          <!-- Blog -->
          <li class="nav-item active">
            <a class="nav-link" href="/blog/">
              blog
              
            </a>
          </li>
          
          <!-- Other pages -->
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          <li class="nav-item ">
              <a class="nav-link" href="/projects/">
                projects
                
              </a>
          </li>
          
          
          
          <li class="nav-item ">
              <a class="nav-link" href="/publications/">
                publications
                
              </a>
          </li>
          
          
          
          <li class="nav-item ">
              <a class="nav-link" href="/service/">
                service
                
              </a>
          </li>
          
          
          
            <div class = "toggle-container">
              <a id = "light-toggle">
                  <i class="fas fa-moon"></i>
                  <i class="fas fa-sun"></i>
              </a>
            </div>
          
        </ul>
      </div>
    </div>
  </nav>

</header>


  <!-- Content -->

  <div class="container mt-5">
    

<div class="post">

  <header class="post-header">
    <h1 class="post-title">Deploying Jakarta EE 9 applications to Payara using Cargo maven plugin</h1>
    <p class="post-meta">December 5, 2020</p>
  </header>

  <article class="post-content">
    <p>Payara Community 5.2020.5 has introduced tech preview functionality to run Jakarta EE 9 on Payara Server and Micro, more details please go to the <a href="https://docs.payara.fish/community/docs/5.2020.6/release-notes/release-notes-2020-5.html#_run_jakarta_ee_9_applications_in_tech_preview">release notes</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XZgar-TMaqJ9r-ovXsLz_A.png" /></figure><p>Originally Payara was a fork of the open-sourced Glassfish, but it includes a bundle of new features that not existed in Glassfish.</p><ul><li>Numerous improvements and quicker bugfixes in comparison to the existing Glassfish</li><li>Java 11(or above) support</li><li>Built-in Microprofile support and ready for cloud native applications</li><li>Many third-party services integration.</li><li>Comprehensive documentation and technical guides</li><li>Commercial support available for paid enterprise users.</li></ul><p>Payara Community is also open sourced, for developers, you use it as an alternative to Glassfish to get better development experience.</p><h3>Prerequisites</h3><p>Make sure you have installed the following software.</p><ul><li>Java 8 or Java 11 (<a href="https://openjdk.java.net/install/">OpenJDK</a> or <a href="https://adoptopenjdk.net/installation.html">AdoptOpenJDK</a>)</li><li><a href="https://www.payara.fish/downloads/payara-platform-community-edition/">Payara Community 5.2020.6</a></li><li><a href="http://maven.apache.org/">Apache Maven</a></li><li>Get to know the basic of <a href="https://codehaus-cargo.github.io/">Cargo maven plugin</a>.</li></ul><h3>Deploy to local Payara server</h3><p>Cargo maven plugin provides a separate <strong>payara</strong> container for Payara server.</p><p>Assume you have downloaded a copy of <a href="https://www.payara.fish/downloads/payara-platform-community-edition/">Payara Community dist</a>, and extracted the files into your local disk.</p><p>Add the following configuration in <em>pom.xml</em> to use the existing Payara domain configuration to run your Jakarta EE 9 applications on the local Payara server.</p><pre>&lt;properties&gt;<br>	&lt;glassfish.home&gt;[ Payara install dir]&lt;/glassfish.home&gt;<br>	&lt;glassfish.domainDir&gt;${glassfish.home}/glassfish/domains&lt;/glassfish.domainDir&gt;<br>	&lt;glassfish.domainName&gt;domain1&lt;/glassfish.domainName&gt;<br>&lt;/properties&gt;<br>&lt;build&gt;<br>	&lt;plugins&gt;<br>		&lt;plugin&gt;<br>			&lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt;<br>			&lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt;<br>			&lt;configuration&gt;<br>				&lt;container&gt;<br>					&lt;containerId&gt;payara&lt;/containerId&gt;<br>					&lt;type&gt;installed&lt;/type&gt;<br>					&lt;home&gt;${glassfish.home}&lt;/home&gt;<br>				&lt;/container&gt;<br>				&lt;configuration&gt;<br>					&lt;type&gt;existing&lt;/type&gt;<br>					&lt;home&gt;${glassfish.domainDir}&lt;/home&gt;<br>					&lt;properties&gt;<br>						&lt;cargo.glassfish.domain.name&gt;${glassfish.domainName}&lt;/cargo.glassfish.domain.name&gt;<br>						&lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt;<br>					&lt;/properties&gt;<br>				&lt;/configuration&gt;<br>			&lt;/configuration&gt;<br>		&lt;/plugin&gt;<br>	&lt;/plugins&gt;<br>&lt;/build&gt;</pre><p>The above configuration is almost same as the one we have discussed in <a href="https://github.com/hantsy/jakartaee9-starter-boilerplate/blob/master/docs/docs/deploy-cargo.md">previous Glassfish post</a>, but we used containerId <strong>payara</strong> here.</p><p>Open a terminal, execute the following command to run your application on the Payara server.</p><pre>mvn clean package cargo:run -Ppayara-local</pre><p>The above command will execute a serise of tasks.</p><ul><li>Build the project and package it into a war archive in the <em>target</em> folder</li><li>Starts up Payara server using the existing <em>domain1</em> configuration</li><li>Deploy the packaged war to the running server</li></ul><p>If you want to use a refresh domain configuration every time to run your applications, try to set the configuration type to <strong>standalone</strong>. Change the server <em>configuration</em> section to the following.</p><pre>&lt;configuration&gt;<br>    &lt;type&gt;standalone&lt;/type&gt;<br>    &lt;properties&gt;<br>        &lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt;<br>    &lt;/properties&gt;<br>&lt;/configuration&gt;</pre><p>A little different from the <strong>existing</strong> configuration, it will create a new domain configuration in the <em>target</em> folder instead of the default <em>domain1</em> in the Payara server.</p><p>In the CI service, such as Github actions, I would like use the official maven-dependency-plugin to prepare a refresh copy of Payara server.</p><pre>&lt;plugin&gt;<br>    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>    &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;<br>    &lt;executions&gt;<br>        &lt;execution&gt;<br>            &lt;id&gt;unpack&lt;/id&gt;<br>            &lt;phase&gt;process-resources&lt;/phase&gt;<br>            &lt;goals&gt;<br>                &lt;goal&gt;unpack&lt;/goal&gt;<br>            &lt;/goals&gt;<br>            &lt;configuration&gt;<br>                &lt;artifactItems&gt;<br>                    &lt;artifactItem&gt;<br>                        &lt;groupId&gt;fish.payara.distributions&lt;/groupId&gt;<br>                        &lt;artifactId&gt;payara&lt;/artifactId&gt;<br>                        &lt;version&gt;${payara.version}&lt;/version&gt;<br>                        &lt;type&gt;zip&lt;/type&gt;<br>                        &lt;overWrite&gt;false&lt;/overWrite&gt;<br>                        &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt;<br>                    &lt;/artifactItem&gt;<br>                &lt;/artifactItems&gt;<br>            &lt;/configuration&gt;<br>        &lt;/execution&gt;<br>    &lt;/executions&gt;<br>&lt;/plugin&gt;</pre><p>Change the glassfish.home property to the following.</p><pre>&lt;glassfish.home&gt;${project.build.directory}/payara5&lt;/glassfish.home&gt;</pre><p>To stop the server, just send a CTRL+C to the running console to stop it.</p><h3>Deploy to a running Payara server</h3><p>Use a remote deployer and runtime configuration, you can use Cargo maven plugin to deploy the application to a running Payara, esp. the Payara server is located in a remote server.</p><pre>&lt;plugin&gt;<br>	&lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt;<br>	&lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt;<br>	&lt;configuration&gt;<br>		&lt;container&gt;<br>			&lt;containerId&gt;payara&lt;/containerId&gt;<br>			&lt;type&gt;remote&lt;/type&gt;<br>		&lt;/container&gt;<br>		&lt;configuration&gt;<br>			&lt;type&gt;runtime&lt;/type&gt;<br>			&lt;properties&gt;<br>				&lt;cargo.remote.username&gt;admin&lt;/cargo.remote.username&gt;<br>				&lt;cargo.remote.password&gt;&lt;/cargo.remote.password&gt;<br>				&lt;cargo.glassfish.admin.port&gt;4848&lt;/cargo.glassfish.admin.port&gt;<br>				&lt;cargo.hostname&gt;localhost&lt;/cargo.hostname&gt;<br>			&lt;/properties&gt;<br>		&lt;/configuration&gt;<br>	&lt;/configuration&gt;<br>	&lt;!-- provides JSR88 client API to deploy on Glassfish/Payara Server --&gt;<br>	&lt;dependencies&gt;<br>		&lt;dependency&gt;<br>			&lt;groupId&gt;org.glassfish.main.deployment&lt;/groupId&gt;<br>			&lt;artifactId&gt;deployment-client&lt;/artifactId&gt;<br>			&lt;version&gt;5.1.0&lt;/version&gt;<br>			&lt;!--&lt;version&gt;${glassfish.version}&lt;/version&gt;--&gt;<br>		&lt;/dependency&gt;<br>	&lt;/dependencies&gt;<br>&lt;/plugin&gt;</pre><p>The above configuration is almost same as the one from <a href="https://github.com/hantsy/jakartaee9-starter-boilerplate/blob/master/docs/docs/deploy-cargo.md">Glassfish doc</a>.</p><p>For a remote server, you can not start and stop the Payara server. Before deploying applications, make sure it is running and accessible from your local environment.</p><p>Use deploy and undeploy goals to perform the deploy and undeploy tasks.</p><pre># deploy applications<br>mvn clean package cargo:deploy -Ppayara-remote</pre><pre># undeploy<br>mvn cargo:undeploy -Ppayara-remote</pre><h3>Verifying the deployed application</h3><p>When the application is deployed successfully, you use curl to verify if the deployed application.</p><pre>curl <a href="http://localhost:8080/jakartaee9-starter-boilerplate/api/greeting/Hantsy">http://localhost:8080/jakartaee9-starter-boilerplate/api/greeting/Hantsy</a><br>{&quot;message&quot;:&quot;Say Hello to Hantsy at 2020-11-14T15:56:10.099&quot;}</pre><blockquote><em>Note: In fact, you can use the </em><em>glassfish5x containerId to deploy Jakarta EE 9 applications to Payara server, and in reverse I think it is also fine when using the </em><em>payara containerId to deploy the application to Glassfish v6.</em></blockquote><p>Grab the <a href="https://github.com/hantsy/jakartaee9-starter-boilerplate/">source codes</a> from my github.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4fff02091cb" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/deploying-jakarta-ee-9-applications-to-payara-using-cargo-maven-plugin-d4fff02091cb">Deploying Jakarta EE 9 applications to Payara using Cargo maven plugin</a> was originally published in <a href="https://itnext.io">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>

  </article>

  

</div>

  </div>

  <!-- Footer -->

  
<footer class="fixed-bottom">
  <div class="container mt-0">
    &copy; Copyright 2021 Hantsy  Bai.
    <span class="mr-auto"></span>
    Powered by <a href="http://jekyllrb.com/" target="_blank">Jekyll</a> with <a href="https://github.com/alshedivat/al-folio">al-folio</a> theme.

    
    

  </div>
</footer>



</body>

<!-- Bootsrap & MDB scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.4.4/umd/popper.min.js" integrity="sha512-eUQ9hGdLjBjY3F41CScH3UX+4JDSI9zXeroz7hJ+RteoCaY+GP/LDoM8AO+Pt+DRFw3nXqsjh9Zsts8hnYv8/A==" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha512-M5KW3ztuIICmVIhjSqXe01oV2bpe248gOxqmlcYrEzAvws7Pw3z6BK0iGbrwvdrUQUhi3eXgtxp5I8PDo9YfjQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.19.1/js/mdb.min.js" integrity="sha512-Mug9KHKmroQFMLm93zGrjhibM2z2Obg9l6qFG2qKjXEXkMp/VDkI4uju9m4QKPjWSwQ6O2qzZEnJDEeCw0Blcw==" crossorigin="anonymous"></script>


<!-- Mansory & imagesLoaded -->
<script defer src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
<script defer src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>
<script defer src="/assets/js/mansory.js" type="text/javascript"></script>





<!-- Load Common JS -->
<script src="/assets/js/common.js"></script>


</html>
